const models = require('../mongo');
const User = models.User;

/**
 * 新增用户
 */
module.exports.newAndSave = ( name:String, loginname:String, pass:String, callback:Function ):void => {
    const user = new User();
    user.name = name;
    user.loginname = loginname;
    user.pass = pass;
    user.save(callback);
}

/**
 * 根据用户名查询用户
 */
module.exports.getUserByName = (name:String, callback:Function):void => {
    User.findOne({ 'name': name }, callback);
}